﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace MachineVision.Domain.Migrations
{
    public partial class AddPatrol : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "PatrolGroups",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NO = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Inactive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    Remarks = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PatrolGroups", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PatrolCars",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NO = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    GroupId = table.Column<int>(type: "int", nullable: false),
                    Inactive = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    Remarks = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PatrolCars", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PatrolCars_PatrolGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "PatrolGroups",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "MissionHistoryInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "EndTime", "StartTime" },
                values: new object[] { new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 3, 1, 13, DateTimeKind.Local).AddTicks(5755) });

            migrationBuilder.InsertData(
                table: "PatrolGroups",
                columns: new[] { "Id", "CreateTime", "Inactive", "NO", "Name", "Remarks", "RoleId" },
                values: new object[] { 1, new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), false, "Test01", "测试组", null, new Guid("4e9ae737-0105-49b5-8a0f-08173b01d77a") });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755) });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755) });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 4,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755) });

            migrationBuilder.UpdateData(
                table: "WarningInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "Time" },
                values: new object[] { new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755) });

            migrationBuilder.InsertData(
                table: "PatrolCars",
                columns: new[] { "Id", "CreateTime", "GroupId", "Inactive", "NO", "Name", "Remarks" },
                values: new object[] { 1, new DateTime(2022, 8, 25, 10, 4, 1, 13, DateTimeKind.Local).AddTicks(5755), 1, false, "001", "car1", null });

            migrationBuilder.CreateIndex(
                name: "IX_PatrolCars_GroupId",
                table: "PatrolCars",
                column: "GroupId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "PatrolCars");

            migrationBuilder.DropTable(
                name: "PatrolGroups");

            migrationBuilder.UpdateData(
                table: "MissionHistoryInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "EndTime", "StartTime" },
                values: new object[] { new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 57, 7, 389, DateTimeKind.Local).AddTicks(3860) });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860) });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 2,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860) });

            migrationBuilder.UpdateData(
                table: "TemperatureInfos",
                keyColumn: "Id",
                keyValue: 4,
                columns: new[] { "CreateTime", "TempTime" },
                values: new object[] { new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860) });

            migrationBuilder.UpdateData(
                table: "WarningInfos",
                keyColumn: "Id",
                keyValue: 1,
                columns: new[] { "CreateTime", "Time" },
                values: new object[] { new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860), new DateTime(2022, 8, 22, 10, 58, 7, 389, DateTimeKind.Local).AddTicks(3860) });
        }
    }
}
